<template>
  <div class="tx-tab">
    <el-tabs v-model="tabs.active" @tab-click="handleClick" v-if="!tabs.hideHeader" >
      <el-tab-pane v-for="(item,i) in tabs.list" :key="i" :name="item.name">
        <div slot="label" class="tx-tab__label">
          {{item.label}}
          <div class="tx-tab__number" v-if="item.number && item.number>0">
            <div>{{item.number}}</div>
          </div>
        </div>
        <component :is="item.component" :name="item.name" :dict="item.dict" :active="tabs.active"/>
      </el-tab-pane>
    </el-tabs>
      
    <div  v-if="tabs.hideHeader"  >
      <component :is="item.component" :name="item.name"  :active="tabs.active" :dict="item.dict"  :content="item"  v-for="(item,i) in tabs.list" :key="i"/>
    </div> 
  </div>
</template>

<script>

export default {
  props: {
    tabs: {
      type: Object,
      default: () => {
        return {
          active: "",
          hideHeader: false,
          list: []
        };
      }
    },
  },
  data() {
    return {

    };
  },

  methods: {
    handleClick(tab, event) {
      this.$emit('change', tab, event)
    },

  }
};
</script>


<style lang="scss">
@import "../../../style/variables.scss";
.tx-tab {
  
  .el-tabs__nav-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    background-color: $c-bd-menu;
    z-index: 1; 
  }
  &__label {
    min-width: 80px;
    max-width: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
  }

  &__number {
    padding: 2px;
    > div {
      margin-top:-10px;
      padding: 0px 0px;
      background-color: $tx-color-primary;
      color: #fff;
      font-size: 12px;
      font-weight: bold;
      border-radius: 10px;
      width: 18px;
      height: 18px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
}
</style>


